#!/bin/bash

#Usage: default network adapter: em1
# ./create_cluster.sh PORT1 PORT2 PORT3

IP=$(ifconfig | grep -A 2 eth0 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1')

REPLICAS=1

PATHS=""
for port in "$@"
do
    PATHS="${PATHS} ${IP}:${port}"
done

./redis-trib.rb create --replicas $REPLICAS ${PATHS}